package cn.iocoder.yudao.module.scrm.dal.mysql.invoice;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.scrm.dal.dataobject.invoice.InvoiceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.scrm.controller.admin.invoice.vo.*;

/**
 * 发票 Mapper
 *
 * @author admin
 */
@Mapper
public interface InvoiceMapper extends BaseMapperX<InvoiceDO> {

    default PageResult<InvoiceDO> selectPage(InvoicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceDO>()
                .eqIfPresent(InvoiceDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(InvoiceDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(InvoiceDO::getContractId, reqVO.getContractId())
                .inIfPresent(InvoiceDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType())
                .likeIfPresent(InvoiceDO::getTicketCompany, reqVO.getTicketCompany())
                .likeIfPresent(InvoiceDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(InvoiceDO::getTaxNumber, reqVO.getTaxNumber())
                .eqIfPresent(InvoiceDO::getAddress, reqVO.getAddress())
                .eqIfPresent(InvoiceDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(InvoiceDO::getAccount, reqVO.getAccount())
                .likeIfPresent(InvoiceDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(InvoiceDO::getPrice, reqVO.getPrice())
                .eqIfPresent(InvoiceDO::getMeetingVenue, reqVO.getMeetingVenue())
                .eqIfPresent(InvoiceDO::getInviter, reqVO.getInviter())
                .eqIfPresent(InvoiceDO::getEnroll, reqVO.getEnroll())
                .eqIfPresent(InvoiceDO::getAcceptPhone, reqVO.getAcceptPhone())
                .eqIfPresent(InvoiceDO::getAcceptEmail, reqVO.getAcceptEmail())
                .eqIfPresent(InvoiceDO::getAttachment, reqVO.getAttachment())
                .eqIfPresent(InvoiceDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .eqIfPresent(InvoiceDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(InvoiceDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(InvoiceDO::getNo,reqVO.getNo())
                .orderByDesc(InvoiceDO::getId));
    }

}